package com.wlc.collection;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description
 * @date 2021-07-11 20:13
 */
public class Hero implements Comparable<Hero> {

    private String name;
    private int hp;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public Hero() {
    }

    public Hero(String name) {
        this.name = name;
    }

    public Hero(String name, int hp) {
        this.name = name;
        this.hp = hp;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "name='" + name + '\'' +
                ", hp=" + hp +
                '}';
    }

    @Override
    public int compareTo(Hero o) {
       // this.hp>o.hp  返回1； 否则返回-1
        return this.hp > o.hp ? 1 : -1;
    }
}
